/*
 * BitrateCellRenderer.java
 *
 * Created on April 2, 2006, 11:50 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.bff.mpd.musicjukebox.ui.components;

import java.awt.Component;
import javax.swing.JTable;
import javax.swing.SwingConstants;

/**
 *
 * @author Bill
 */
public class BitrateCellRenderer extends SongCellRenderer {
    
    public BitrateCellRenderer() {
        setHorizontalAlignment(SwingConstants.CENTER);
    }
    
    @Override
    public Component getTableCellRendererComponent(
            JTable table,
            Object value,
            boolean isSelected,
            boolean hasFocus,
            int row,
            int column) {
        super.setFont(table.getFont());
        
        String label = null;

        if(value instanceof Number) {
            int i = (Integer)value/1000;
            label = Integer.toString(i)+" kbps";
        }
    
        try {
            setText(label);
        } catch(Exception e) {
            setText(null);
        }
        
        setColors(table, row, isSelected);
        
        return this;
    }   
}

